<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页-课程列表</title>
</head>
<body>
项目首页
<table border="1">
    <tr><td>序号</td><td>课程名称</td><td>简介</td><td>教师</td><td>操作</td></tr>
    <tbody id="tb"></tbody>
</table>
</body>
<script src="/js/jquery.min.js"></script>
<script>
    $(function (){
        showCourse();
    })
    function showCourse(){
        $.ajax({
            url:"/course/query",
            method:'get',
            dataType:'json',
            success:function (res){
                $("#tb").empty();
                var row ='';
                $.each(res,function (i,v){
                    row += "<tr><td>"+(i+1)+"</td><td>"+v.cname+"</td><td>"+v.mark+"</td><td>"+v.tea+"</td><td><button onclick='del("+v.id+")'>删除</button></td></tr>";
                });
                $("#tb").append(row);
            }
        });
    }
    function del(i){
        $.ajax({
            url:"/course/del",
            method:'get',
            data:{id:i},
            dataType:'json',
            success:function (res){
                alert(res.msg || '已删除');
                showCourse();
            }
        });
    }
</script>
</html>